<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/6/17
 * Time: 17:56
 */

namespace doumiaoduo\ueditor\actions;


use doumiaoduo\aliyun\OssuploaderHelper;
use yii\base\Action;
use yii\web\Response;

class UploadfileAction extends Action{


    private $_config;

    public function init(){
        $this->_config=\Yii::$app->params['aliyunoss'];
        parent::init();
    }

    public function run(){
        \Yii::$app->response->format=Response::FORMAT_JSON;
        $config = array(
            "pathFormat" =>$this->_config['filePathFormat'],//filePathFormat为"/uploadfiles/web/site/file/{yyyy}{mm}{dd}/{time}{rand:6}"
            "maxSize" => $this->_config['fileMaxSize'],
            "allowFiles" => $this->_config['fileAllowFiles']
        );
        $fieldName = $this->_config['fileFieldName'];//文件名uploadfile

        $up=new OssuploaderHelper($fieldName,$config);
        return $up->getOssFileInfo();

    }

}